package com.syt.tank.message;

import com.syt.mina.message.IMessage;

import flex.messaging.io.amf.ASObject;

public abstract class AbstractMessage implements IMessage {

	
	private String msgId;
	private String playerFrom;
	private String playerTo;
	private String requestId;
	
	public AbstractMessage(String playerFrom, String playerTo , String msgId){
		this.playerFrom = playerFrom;
		this.playerTo = playerTo;
		this.msgId = msgId;
	}
	
	@Override
	public Object getMessage() {
		ASObject as = getAsObject();
		as.put("msgId",  this.msgId);
		as.put("playerId",  this.playerFrom);
		if(requestId != null){
			as.put("requestId",  this.requestId);
		}
		return as;
	}
	
	abstract ASObject getAsObject();

	public String getPlayerFrom() {
		return playerFrom;
	}

	public String getPlayerTo() {
		return playerTo;
	}

	public String getMsgId() {
		return msgId;
	}

	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}
}
